package javaCode.chapter13.set_;

/**
 * @author 徐州城
 * @version 1.0
 */
public class HashSetStructure {
    @SuppressWarnings("all")
    public static void main(String[] args) {
        //模拟 HashSet的底层 (HashMap) 的底层结构

        //1. 创建一个数组，数组的类型是 Node[]
        //2. 有些人，直接把 Node[] 数组称为 表
        Node[] table = new Node[16];
        //3. 创建结点
        Node john = new Node("john", null);

        table[2] = john;
        Node jack = new Node("jack", null);
        john.next = jack; //将jack 结点挂载到 john
        Node rose = new Node("Rose", null);
        jack.next = rose; //将rose 结点挂载到 jack
        Node luck = new Node("luck");
        table[3] = luck;

        System.out.println("table=" + table);
    }
}

class Node{ //结点，存储数据，可以指向下一个结点，从而形成链表
    Object item; //存放数据
    Node next; // 指向下一个结点

    public Node(Object item, Node next) {
        this.item = item;
        this.next = next;
    }

    public Node(Object item) {
        this.item = item;
    }
}
